package lab02.test34;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test34 {
    public static void main(String[] args) {
        List<String> words = new ArrayList<String>();
        words.add("apple");
        words.add("grape");
        words.add("banana");
        words.add("pear");

        String a = Collections.max(words);
        String b = Collections.min(words);
        System.out.println("最大值："+a);
        System.out.println("最小值："+b);

        System.out.println("排序之前：");
        for (String word :words){
            System.out.print(words.indexOf(word)+":");
            System.out.println(word);
        }

        Collections.sort(words);
        System.out.println("排序之后：");
        for (String word :words){
            System.out.print(words.indexOf(word)+":");
            System.out.println(word);
        }
    }
}
